// 有几种调用方式？ 同步 异步

//创建一个文件

let fs = require("fs");

// fs.writeFileSync("./demo.txt","thisidemo");

// fs.writeFile('./demo2.txt','thisisdemo2',function(err){
//     console.log(err);
// });

// let data=fs.readFileSync('./demo.txt',{encoding:'utf8',flag:'r'});
// console.log(data)
fs.readFile('./demo.txt',{encoding:'utf8'},function(err,data){
    //console.log(data);
})

//流文件读取，去看看

let stream=fs.createReadStream('./demo.txt',{encoding:'utf8',highWaterMark:3});

stream.on('data',function(chunk){//chunk 默认大小？
   console.log(chunk+'=======================')
});


